<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>气体检测</title>
    <link rel="stylesheet" href="../css/theme.css" />
    <link rel="stylesheet" href="../css/common.css" />
    <link rel="stylesheet" href="../css/iconfont.css" />
    <link rel="stylesheet" href="../css/iconfont.ttf" />
    <link rel="stylesheet" href="../layui-v2.8.17/layui/css/layui.css" />
    <!-- VConsole 初始化 -->
    <script src="../lib/vconsole/vconsole.min.js"></script>
    <script src="../js/vconsole-init.js"></script>
    <script src="../layui-v2.8.17/layui/layui.js"></script>
    <script src="../lib/jquery.js"></script>
    <script src="../lib/echarts.min.js"></script>
    <script src="../lib/utils.js"></script>
    <script src="../js/common.js"></script>
    <script src="../js/widgets.js"></script>
    <script src="../js/warom-utils.js"></script>
    <script src="../js/android-interface.js"></script>
    <!-- 全局配置 -->
    <script src="../js/config.js"></script>
    <!-- 模拟数据 -->
    <script src="../js/mock/mock-gas-data.js"></script>
    <script src="../js/gasmonitoring.js"></script>
    <style>
      /* 全局样式 */
      * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
        font-family: "Roboto", "PingFang SC", "Microsoft YaHei", sans-serif;
      }
      
      body {
        background: linear-gradient(130deg, var(--theme-gradient-start) 0%, var(--theme-gradient-end) 100%);
        color: var(--theme-text-color);
        padding: 16px;
        height: 100vh;
        width: 100vw;
        overflow: hidden;
        padding-top: 0;
      }
      
      /* 主要内容区域 */
      main {
        height: calc(100vh - 80px);
        padding: 0 16px;
        margin-top: 16px;
      }
      
      /* 自定义标签样式 */
      .layui-tab-title {
        border: none;
        height: 48px;
        border-bottom-style: none !important;
      }
      
      .layui-tab-title li {
        color: rgba(255, 255, 255, 0.7) !important;
        font-size: 18px;
        min-width: 100px;
        padding: 0 16px;
      }
      
      .layui-tab-title .layui-this {
        color: #FFFFFF !important;
        font-weight: 500;
      }
      
      .layui-tab-title .layui-this:after {
        height: 3px;
        border: none;
        background-color: var(--theme-gradient-start);
      }
      
      .layui-tab-content {
        padding: 16px 0;
      }
      
      /* 主内容区域 */
      .main-content {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: repeat(2, 1fr);
        gap: 24px;
        height: calc(100vh - 180px);
      }
      
      /* 表格样式 */
      .table {
        background-color: var(--theme-card-bg);
        border-radius: 12px;
        box-shadow: 0 1px 3px var(--theme-card-shadow) inset;
        overflow: hidden;
        transition: transform 0.2s;
        border: 1px solid var(--theme-card-border);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
      }
      
      .table:hover {
        transform: translateY(-2px);
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2) inset;
      }
      
      table {
        width: 100%;
        height: 100%;
        border-collapse: collapse;
      }
      
      table thead tr {
        height: 48px;
        background-color: rgba(0, 0, 0, 0.2);
      }
      
      table thead td {
        padding: 0 24px;
        font-size: 18px;
        font-weight: 500;
        text-align: left;
        color: var(--theme-text-color);
      }
      
      table thead td:nth-child(2) {
        text-align: right;
      }
      
      table tbody tr {
        height: 52px;
        border-bottom: 1px solid var(--theme-card-border);
      }
      
      table tbody tr:last-child {
        border-bottom: none;
      }
      
      table tbody td {
        padding: 12px 24px;
        font-size: 16px;
        color: var(--theme-text-color);
      }
      
      table tbody td:first-child {
        display: flex;
        flex-direction: column;
      }
      
      table tbody td:first-child span:first-child {
        font-weight: 500;
      }
      
      table tbody td:first-child span:last-child {
        color: rgba(255, 255, 255, 0.6);
        font-size: 14px;
        margin-top: 4px;
      }
      
      table tbody td:last-child {
        text-align: right;
      }
      
      table tbody td:last-child div {
        display: flex;
        justify-content: flex-end;
        align-items: baseline;
      }
      
      table tbody td:last-child span:first-child {
        font-size: 24px;
        font-weight: bold;
        margin-right: 8px;
      }
      
      table tbody td:last-child span:last-child {
        color: rgba(255, 255, 255, 0.6);
        font-size: 14px;
      }
      
      /* 异常数值高亮 */
      .warning {
        color: #FFA000;
      }
      
      .danger {
        color: #F44336;
      }
      
      /* 加载和错误提示样式 */
      #loading {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        display: flex;
        justify-content: center;
        align-items: center;
        z-index: 9999;
      }
      
      #loading::after {
        content: "";
        width: 50px;
        height: 50px;
        border: 5px solid rgba(255, 255, 255, 0.3);
        border-radius: 50%;
        border-top-color: var(--theme-text-color);
        animation: spin 1s infinite linear;
      }
      
      @keyframes spin {
        to { transform: rotate(360deg); }
      }
      
      #error-message {
        position: fixed;
        top: 20px;
        left: 50%;
        transform: translateX(-50%);
        background-color: #F44336;
        color: white;
        padding: 10px 20px;
        border-radius: 4px;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
        z-index: 9999;
        display: none;
      }
      
      .empty-data {
        grid-column: 1 / -1;
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 18px;
        color: rgba(255, 255, 255, 0.6);
      }
      
      /* 刷新按钮 */
      .refresh-button {
        position: absolute;
        top: 16px;
        right: 16px;
        width: 36px;
        height: 36px;
        background-color: var(--theme-card-bg);
        border-radius: 50%;
        display: flex;
        justify-content: center;
        align-items: center;
        cursor: pointer;
        transition: background-color 0.3s;
        border: 1px solid var(--theme-card-border);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
      }
      
      .refresh-button:hover {
        background-color: rgba(255, 255, 255, 0.3);
      }
      
      .refresh-button i {
        color: var(--theme-text-color);
        font-size: 20px;
      }
      
      /* 历史数据样式 */
      .history-container {
        display: flex;
        flex-direction: column;
        height: calc(100vh - 180px);
        color: var(--theme-text-color);
      }
      
      .filter-area {
        display: flex;
        flex-wrap: wrap;
        padding: 16px;
        background-color: var(--theme-card-bg);
        border-radius: 8px;
        margin-bottom: 16px;
        border: 1px solid var(--theme-card-border);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
      }
      
      .filter-item {
        margin-right: 20px;
        margin-bottom: 10px;
        display: flex;
        align-items: center;
      }
      
      .filter-item label {
        margin-right: 8px;
        font-size: 14px;
        color: rgba(255, 255, 255, 0.8);
      }
      
      .filter-item select,
      .filter-item input {
        background-color: rgba(255, 255, 255, 0.2);
        border: 1px solid var(--theme-card-border);
        color: var(--theme-text-color);
        border-radius: 4px;
        padding: 6px 12px;
        width: 160px;
      }
      
      .filter-item.date-range {
        width: 250px;
      }
      
      .chart-container {
        flex: 0 0 300px;
        background-color: var(--theme-card-bg);
        border-radius: 8px;
        padding: 16px;
        margin-bottom: 16px;
        border: 1px solid var(--theme-card-border);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
      }
      
      .table-container {
        flex: 1;
        background-color: var(--theme-card-bg);
        border-radius: 8px;
        padding: 16px;
        overflow-y: auto;
        border: 1px solid var(--theme-card-border);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
      }
      
      /* 自定义layui表格样式 */
      .layui-table {
        background-color: transparent;
        color: var(--theme-text-color);
      }
      
      .layui-table thead tr {
        background-color: rgba(0, 0, 0, 0.3);
      }
      
      .layui-table tbody tr:hover {
        background-color: rgba(255, 255, 255, 0.1);
      }
      
      .layui-table td, .layui-table th {
        border-color: var(--theme-card-border);
      }
      
      /* Toast通知样式 */
      .toast {
        position: fixed;
        bottom: 80px;
        left: 50%;
        transform: translateX(-50%) translateY(100px);
        background-color: rgba(0, 0, 0, 0.8);
        color: var(--theme-text-color);
        padding: 12px 24px;
        border-radius: 24px;
        font-size: 15px;
        font-weight: 500;
        z-index: 10000;
        opacity: 0;
        transition: transform 0.3s ease, opacity 0.3s ease;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
        max-width: 80%;
        text-align: center;
      }
      
      .toast.show {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
      }
      
      /* 响应式调整 */
      @media screen and (max-width: 1100px) {
        .main-content {
          grid-template-columns: repeat(2, 1fr);
          grid-template-rows: repeat(3, 1fr);
        }
      }
    </style>
  </head>
  <body>
    <!-- 公共头部 -->
    <header class="common-header"></header>
    
    <main>
      <!-- 自定义标签样式 -->
      <div class="layui-tab layui-tab-brief" lay-filter="gas-tabs">
        <ul class="layui-tab-title">
          <li class="layui-this">实时监测</li>
          <!-- <li>二氧化碳</li>
          <li>磷化氢</li>
          <li>温湿度</li> -->
        </ul>
        <div class="layui-tab-content">
          <!-- 氧气浓度标签页 -->
          <div class="layui-tab-item layui-show">
            <div class="main-content" id="oxygen-content">
              <!-- 氧气浓度数据表格将被JS动态生成 -->
            </div>
          </div>
          
          <!-- 二氧化碳标签页 -->
          <div class="layui-tab-item">
            <div class="main-content" id="co2-content">
              <!-- 二氧化碳数据表格将被JS动态生成 -->
            </div>
          </div>
          
          <!-- 磷化氢标签页 -->
          <div class="layui-tab-item">
            <div class="main-content" id="ph3-content">
              <!-- 磷化氢数据表格将被JS动态生成 -->
            </div>
          </div>
          
          <!-- 温湿度标签页 -->
          <div class="layui-tab-item">
            <div class="main-content" id="temp-humidity-content">
              <!-- 温湿度数据表格将被JS动态生成 -->
            </div>
          </div>
        </div>
      </div>
    </main>

    <script>
      document.addEventListener('DOMContentLoaded', function() {
        // 加载保存的主题
        loadSavedTheme();
        
        // 初始化公共头部
        initCommonHeader('气体检测', true);
        
        // 初始化标签页
        layui.use('element', function() {
          var element = layui.element;
          // 监听标签切换
          element.on('tab(gas-tabs)', function(data) {
            console.log('切换到标签: ' + data.index);
            // 可以在这里根据标签索引执行相应的操作
          });
        });
      });
    </script>
  </body>
</html>